export const getImageDimensions = (url: string) => {
  return new Promise<{ naturalWidth: number, naturalHeight: number }>((resolve, reject) => {
    const img = new Image()
    img.src = url
    img.addEventListener('load', () => {
      const { naturalHeight, naturalWidth } = img
      resolve({ naturalWidth, naturalHeight })
    })
    img.addEventListener('error', () => {
      reject(new Error('There was some problem with the image. '))
    })
  })
}